package com.gl.order.commom;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

@Data
@Slf4j
public class ResultBean<T> implements Serializable {

    //  未登录
    public static final int NO_LOGIN = -1;
    // 成功
    public static final int SUCCESS = 0;
    // 失败
    public static final int FAIL = 1;
    // 没有权限
    public static final int NO_PERMISSION = 2;

    private String msg;

    private int code;

    private T data;

    public ResultBean(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public ResultBean(int code, String msg,T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResultBean<T> success() {
        return new ResultBean<T>(SUCCESS,"success");
    }
    public static <T> ResultBean<T> success(String msg) {
        return new ResultBean<T>(SUCCESS,msg);
    }
    public static <T> ResultBean<T> success(T data) {
        return new ResultBean<T>(SUCCESS,"success",data);
    }
    public static <T> ResultBean<T> failed(int code,String msg) {
        return new ResultBean<T>(code,msg);
    }
    public static <T> ResultBean<T> failed(String msg) {
        return new ResultBean<T>(FAIL,msg);
    }


}
